package com.lixumin.user.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import com.lixumin.user.entity.Emploee;
import com.lixumin.user.service.EmploeeService;


/**
 * spring传参方式
 */
@Controller
//1在方法参数上带上request
public class ValueController {
//	@RequestMapping("/value1")
//	public ModelAndView value1(HttpServletRequest request){
//		System.out.println("ValueController.value1()");
//		String userName = request.getParameter("userName");
//		String password = request.getParameter("password");
//		User u = new User(userName,password);
//		System.out.println(u);
//		ModelAndView mv = new ModelAndView("input.jsp");
//		return mv;
//	}
//	//2,前台参数的key和后台方法的形参名对应就能自动注入//post请求
//	@RequestMapping("/value2")
//	public ModelAndView value2(String userName,String password){
//		System.out.println("ValueController.value2()");
//		User u=new User(userName,password);
//		System.out.println(u);
//		ModelAndView mv=new ModelAndView("input.jsp");
//		return mv;
//	}
//	@RequestMapping("/value3")//post请求
//	public ModelAndView value3(@RequestParam("name") String userName,String password){
//		System.out.println("ValueController.value3()");
//		User u=new User(userName,password);
//		System.out.println(u);
//		ModelAndView mv=new ModelAndView("input.jsp");
//		return mv;
//	}
//
//	//3:对象传参方式
//	@RequestMapping("/value4")//post请求
//	public ModelAndView value4(User u){
//		System.out.println("value");
//		System.out.println(u);
//		ModelAndView mv=new ModelAndView("input.jsp");
//		return mv;
//	}
//	//4,地址栏传參  localhost/delete/5
//	@RequestMapping("/delete/{id}")
//	public ModelAndView Value5(@PathVariable("id") Long id,Model model ){
//		System.out.println("delete");
//		System.out.println(id);	
//		model.addAttribute("msg","lxm");
//		ModelAndView mv=new ModelAndView("show");
//		return mv;
//	}
//	//4,地址栏传參  localhost/delete/5(处理get请求)
//		@RequestMapping("/delete/{id}/{name}")
//		public String Value6(@PathVariable("id") Long sid ,@PathVariable("name") String sname){
//			System.out.println("delete");
//			System.out.println(sid);	
//			System.out.println(sname);
//			//ModelAndView mv=new ModelAndView("input.jsp");
//			return "redirect:/input.jsp";
//		}
//		@RequestMapping("/value7")
//		@ResponseBody//注意必须写(后端向前端发送json格式的数据)
//		public User value7(){
//			User user=new User("LXM", "lll");
//			return user;//把对象向前端发送成json类型的数据
//		}
		@Autowired
		
		 EmploeeService service;
		

		@RequestMapping("/value8")//前端向后端发json数据
		public String value8(@RequestBody Emploee  e){
			
			service.createEmploee(e);
			System.out.println("value");
			System.out.println("我把代码修改了");
			return "show";
		}

	
	

}
